import request from '../utils/request'

// 分页查询教师列表
export function getTeacherList(params) {
  // 确保所有必需参数都有值
  const requestParams = {
    pageNum: params.pageNum || 1,
    pageSize: params.pageSize || 10,
    teNo: params.teNo !== undefined && params.teNo !== '' ? params.teNo : -1,
    teName: params.teName !== undefined ? params.teName : '',
    teSex: params.teSex !== undefined && params.teSex !== '' ? params.teSex : -1, // 修复：0是有效值
    tePhone: params.tePhone !== undefined ? params.tePhone : ''
  }
  
  console.log('发送请求参数:', requestParams) // 调试用
  console.log('原始参数:', params) // 调试用
  
  return request({
    url: '/teacher/listPage',
    method: 'get',
    params: requestParams
  })
}

// 根据id查询教师详情
export function getTeacherDetail(id) {
  return request({
    url: '/teacher/select',
    method: 'get',
    params: { id }
  })
}

// 新增教师
export function addTeacher(data) {
  return request({
    url: '/teacher/save',
    method: 'post',
    data
  })
}

// 编辑教师
export function updateTeacher(data) {
  return request({
    url: '/teacher/update',
    method: 'put',
    data
  })
}

// 删除教师
export function deleteTeacher(id) {
  return request({
    url: '/teacher/delete',
    method: 'delete',
    params: { id }
  })
}

// 获取教师课表
export function getTeacherSchedule(params) {
  return request({
    url: '/teacher/schedule',
    method: 'get',
    params
  })
}

// 获取教师反馈列表
export function getTeacherFeedback(params) {
  return request({
    url: '/teacher/feedback',
    method: 'get',
    params
  })
}

// 提交教师反馈
export function submitTeacherFeedback(data) {
  return request({
    url: '/teacher/feedback',
    method: 'post',
    data
  })
}

// 更新教师反馈
export function updateTeacherFeedback(data) {
  return request({
    url: '/teacher/feedback',
    method: 'put',
    data
  })
}

// 删除教师反馈
export function deleteTeacherFeedback(id) {
  return request({
    url: '/teacher/feedback',
    method: 'delete',
    params: { id }
  })
}

// 获取教师排课诉求列表
export function getTeacherRequest(params) {
  return request({
    url: '/teacher/request',
    method: 'get',
    params
  })
}

// 提交教师排课诉求
export function submitTeacherRequest(data) {
  return request({
    url: '/teacher/request',
    method: 'post',
    data
  })
}

// 更新教师排课诉求
export function updateTeacherRequest(data) {
  return request({
    url: '/teacher/request',
    method: 'put',
    data
  })
}

// 删除教师排课诉求
export function deleteTeacherRequest(id) {
  return request({
    url: '/teacher/request',
    method: 'delete',
    params: { id }
  })
}